﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Zor_DAL;
using Zor_Tools;
using Zor_Modes;

namespace Zor_Bll
{
    public class Flow_Bll
    {
        /// <summary>
        /// 获取 - 办事流程列表
        /// </summary>
        /// <returns></returns>
        public static List<M_Information> GetFlowList()
        {
            return Notice_DAL<M_Information>.GetNoticeList(2);
        }

        /// <summary>
        /// 获取办事流程详情
        /// </summary>
        /// <param name="id">id</param>
        /// <returns></returns>
        public static M_Information GetTById(int id)
        {
            return Notice_DAL<M_Information>.GetT(id);
        }

        /// <summary>
        /// 新增 - 办事流程
        /// </summary>
        /// <param name="infomation"></param>
        /// <returns></returns>
        public static BaseAnswer AddFlow(M_Information infomation)
        {
            infomation.Info_Date = DateTime.Now;
            infomation.Info_Type = M_Information.NoticeType.流程查询;
            infomation.Info_SubMation = ReplceHTML.NoHTML(infomation.Info_Mation);

            BaseAnswer bar = Notice_DAL<M_Information>.AddNotice(infomation);
            if (bar.AnswerType == BaseAnswer.Answers.Succee)
                bar.AnswerMeg = "新增成功！";
            else if (bar.AnswerType == BaseAnswer.Answers.Failure)
                bar.AnswerMeg = "新增失败！";
            return bar;
        }

        /// <summary>
        /// 编辑 - 办事流程
        /// </summary>
        /// <param name="infomation"></param>
        /// <returns></returns>
        public static BaseAnswer EditFlow(M_Information infomation)
        {
            infomation.Info_Type = M_Information.NoticeType.流程查询;
            infomation.Info_Date = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd HH:mm"));
            infomation.Info_SubMation = ReplceHTML.NoHTML(infomation.Info_Mation);

            BaseAnswer bar = Notice_DAL<M_Information>.EditNotice(infomation);
            if (bar.AnswerType == BaseAnswer.Answers.Succee)
                bar.AnswerMeg = "修改成功！";
            else if (bar.AnswerType == BaseAnswer.Answers.Failure)
                bar.AnswerMeg = "修改失败！";
            return bar;
        }

        /// <summary>
        /// 删除 - 办事流程
        /// </summary>
        /// <param name="ids">唯一标识数组  </param>
        /// <returns></returns>
        public static BaseAnswer DeleteFlow(int[] ids)
        {
            BaseAnswer bar = Notice_DAL<M_Information>.DeleteNotice(ids);
            if (bar.AnswerType == BaseAnswer.Answers.Succee)
                bar.AnswerMeg = "删除成功！";
            else if (bar.AnswerType == BaseAnswer.Answers.Failure)
                bar.AnswerMeg = "删除失败！";
            return bar;
        }

    }
}
